<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="../../layui/css/layui.css">
    <link rel="stylesheet" href="../../css/userNumber.css">
    <link rel="stylesheet" href="../../layui/css/formSelects-v4.css">
    <!--<link rel="stylesheet" href="../../css/main.css">-->
    <title>分类编号</title>
</head>
<style>
    .operation {
        margin: 0 5px;
        padding: 5px 6px;
        cursor: pointer;
        border-radius: 5px;
        color: #FFF;
    }

    .operation:nth-child(1) {
        background: #019688;
    }

    .operation:nth-child(2) {
        background: #FF5823;
    }
</style>
<body>
<div id="userNumber">
    <div class="layui-tab layui-tab-card" lay-filter="types"  style="height: 800px!important;">
        <div class="top">
            <ul class="layui-tab-title">
                <li class="layui-this">材料科</li>
                <li>人工科</li>
                <li>机械科</li>
                <li>职工科</li>
                <li>设备科</li>
                <li>其它费用科</li>
            </ul>
            <div>
                <button type="button" class="layui-btn" @click="adduser(1)"><i class="layui-icon">&#xe608;</i> 添加
                </button>
                <!--<button type="button" class="layui-btn layui-btn-danger"><i class="layui-icon">&#xe640;</i>删除</button>-->
                <button type="button" @click="exports" class="layui-btn layui-btn-normal"><i
                        class="layui-icon">&#xe621;</i>导出
                </button>
            </div>
        </div>
        <div class="layui-tab-content" style="height: 100px;">
            <div class="layui-tab-item layui-show tabs">
                <table border="1px" cellpadding="0" cellspacing="0" id="t1" bordercolor="#c2c2c2">
                    <tr style="font-weight: bold">
                        <td>序号</td>
                        <td>操作</td>
                        <td>填写人</td>
                        <td>填写日期</td>
                        <td>材料编号</td>
                        <td>材料名称</td>
                        <td>规格型号</td>
                    </tr>
                    <tr v-for="(item, index) in arr1" :key="item.id">
                        <td>{{item.id}}</td>
                        <td>
                            <span class="operation" @click="adduser(2, item.id)">编辑</span>
                            <span @click="del(item.id)" class="operation">删除</span>
                        </td>
                        <td>{{item.user_name}}</td>
                        <td>{{item.createtime}}</td>
                        <td>{{item.cl_num}}</td>
                        <td>{{item.cl_name}}</td>
                        <td>{{item.cl_model}}</td>
                    </tr>
                    <tr v-if="arr1.length == 0">
                        <td colspan="7" style="text-align: center">暂无数据</td>
                    </tr>
                </table>
            </div>
            <div class="layui-tab-item">
                <table border="1px" cellpadding="0" cellspacing="0" id="t2" bordercolor="#c2c2c2">
                    <tr style="font-weight: bold">
                        <td>序号</td>
                        <td>操作</td>
                        <td>填写人</td>
                        <td>填写日期</td>
                        <td>姓名</td>
                        <td>人员编号</td>
                        <td>工种</td>
                    </tr>
                    <tr v-for="(item, index) in arr2" :key="item.id" >
                        <td>{{item.id}}</td>
                        <td>
                            <span class="operation" @click="adduser(2, item.id)">编辑</span>
                            <span @click="del(item.id)" class="operation">删除</span>
                        </td>
                        <td>{{item.user_name}}</td>
                        <td>{{item.createtime}}</td>
                        <td>{{item.ry_name}}</td>
                        <td>{{item.ry_num}}</td>
                        <td>{{item.ry_type}}</td>

                    </tr>
                    <tr v-if="arr2.length == 0">
                        <td colspan="6" style="text-align: center">暂无数据</td>
                    </tr>
                </table>
            </div>
            <div class="layui-tab-item">
                <table border="1px" cellpadding="0" cellspacing="0" id="t3" bordercolor="#c2c2c2">
                    <tr style="font-weight: bold">
                        <td>序号</td>
                        <td>操作</td>
                        <td>填写人</td>
                        <td>填写日期</td>
                        <td>机械编号</td>
                        <td>机械名称</td>
                        <td>规格型号</td>
                    </tr>
                    <tr v-for="(item, index) in arr3" :key="item.id">
                        <td>{{item.id}}</td>
                        <td>
                            <span class="operation"  @click="adduser(2, item.id)">编辑</span>
                            <span @click="del(item.id)" class="operation">删除</span>
                        </td>
                        <td>{{item.user_name}}</td>
                        <td>{{item.createtime}}</td>
                        <td>{{item.jx_num}}</td>
                        <td>{{item.jx_name}}</td>
                        <td>{{item.jx_model}}</td>
                    </tr>
                    <tr v-if="arr3.length == 0">
                        <td colspan="7" style="text-align: center">暂无数据</td>
                    </tr>
                </table>
            </div>
            <div class="layui-tab-item">
                <table border="1px" cellpadding="0" cellspacing="0" id="t4" bordercolor="#c2c2c2">
                    <tr style="font-weight: bold">
                        <td>序号</td>
                        <td>操作</td>
                        <td>填写人</td>
                        <td>填写日期</td>
                        <td>员工编号</td>
                        <td>职位</td>
                        <td>星级</td>
                        <td>姓名</td>
                    </tr>
                    <tr v-for="(item, index) in arr4" :key="item.id">
                        <td>{{item.id}}</td>
                        <td>
                            <span class="operation" @click="adduser(2, item.id)">编辑</span>
                            <span @click="del(item.id)" class="operation">删除</span>
                        </td>
                        <td>{{item.user_name}}</td>
                        <td>{{item.createtime}}</td>
                        <td>{{item.yg_num}}</td>
                        <td>{{item.yg_position}}</td>
                        <td>{{item.yg_star}}</td>
                        <td>{{item.yg_name}}</td>
                    </tr>
                    <tr v-if="arr4.length == 0">
                        <td colspan="8" style="text-align: center">暂无数据</td>
                    </tr>
                </table>
            </div>
            <div class="layui-tab-item">
                <table border="1px" cellpadding="0" cellspacing="0" id="t5" bordercolor="#c2c2c2">
                    <tr style="font-weight: bold">
                        <td>序号</td>
                        <td>操作</td>
                        <td>填写人</td>
                        <td>填写日期</td>
                        <td>设备编号</td>
                        <td>资产名称</td>
                        <td>资产总额</td>
                        <td>摊销年限</td>
                    </tr>
                    <tr v-for="(item, index) in arr5" :key="item.id">
                        <td>{{item.id}}</td>
                        <td>
                            <span class="operation"  @click="adduser(2, item.id)">编辑</span>
                            <span @click="del(item.id)" class="operation">删除</span>
                        </td>
                        <td>{{item.user_name}}</td>
                        <td>{{item.createtime}}</td>
                        <td>{{item.sb_num}}</td>
                        <td>{{item.mon_name}}</td>
                        <td>{{item.zc_total}}</td>
                        <td>{{item.cc_year}}</td>
                    </tr>
                    <tr v-if="arr5.length == 0">
                        <td colspan="8" style="text-align: center">暂无数据</td>
                    </tr>
                </table>
            </div>
            <div class="layui-tab-item">
                <table border="1px" cellpadding="0" cellspacing="0" id="t6" bordercolor="#c2c2c2">
                    <tr style="font-weight: bold">
                        <td>序号</td>
                        <td>操作</td>
                        <td>填写人</td>
                        <td>填写日期</td>
                        <td>费用编号</td>
                        <td>名称</td>
                        <td>分类名称</td>
                    </tr>
                    <tr v-for="(item, index) in arr6" :key="item.id">
                        <td>{{item.id}}</td>
                        <td>
                            <span class="operation" @click="adduser(2, item.id)">编辑</span>
                            <span @click="del(item.id)" class="operation">删除</span>
                        </td>
                        <td>{{item.username}}</td>
                        <td>{{item.createtime}}</td>
                        <td>{{item.fy_num}}</td>
                        <td>{{item.fy_name}}</td>
                        <td>{{item.fy_type}}</td>
                    </tr>
                    <tr v-if="arr6.length == 0">
                        <td colspan="7" style="text-align: center">暂无数据</td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
</div>
<div class="x-body" id="materialindex" style="display: none;padding-top: 10px">
    <form class="layui-form" id="cl">
        <div class="layui-form-item">
            <label for="cl_num" class="layui-form-label" v-show="tabs == 0">
                <span class="x-red">*</span>材料编号
            </label>
            <div class="layui-input-inline">
                <input type="text" id="cl_num" name="cl_num" required lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="cl_name" class="layui-form-label">
                <span class="x-red">*</span>材料名称
            </label>
            <div class="layui-input-inline">
                <input type="text" id="cl_name" name="cl_name" required lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="cl_model" class="layui-form-label">
                <span class="x-red">*</span>规格型号
            </label>
            <div class="layui-input-inline">
                <input type="text" id="cl_model" name="cl_model" required lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
            </label>
            <button class="layui-btn" type="button" lay-filter="add" lay-submit="">
                保存
            </button>
        </div>
    </form>
</div>
<div class="x-body" id="workerindex" style="display: none;padding-top: 10px">
    <form class="layui-form" id="c2">
        <div class="layui-form-item">
            <label for="ry_num" class="layui-form-label">
                <span class="x-red">*</span>人工编号
            </label>
            <div class="layui-input-inline">
                <input type="text" id="ry_num" name="ry_num" required lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="ry_type" class="layui-form-label">
                <span class="x-red">*</span>工种
            </label>
            <div class="layui-input-inline">
                <input type="text" id="ry_type" name="ry_type" required lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="ry_name" class="layui-form-label">
                <span class="x-red">*</span>姓名
            </label>
            <div class="layui-input-inline">
                <input type="text" id="ry_name" name="ry_name" required lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
            </label>
            <button class="layui-btn" type="button" lay-filter="add" lay-submit="">
                保存
            </button>
        </div>
    </form>
</div>
<div class="x-body" id="mechanicalindex" style="display: none;padding-top: 10px">
    <form class="layui-form" id="c3">
        <div class="layui-form-item">
            <label for="jx_num" class="layui-form-label">
                <span class="x-red">*</span>机械编号
            </label>
            <div class="layui-input-inline">
                <input type="text" id="jx_num" name="jx_num" required lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="jx_name" class="layui-form-label">
                <span class="x-red">*</span>机械名称
            </label>
            <div class="layui-input-inline">
                <input type="text" id="jx_name" name="jx_name" required lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="jx_model" class="layui-form-label">
                <span class="x-red">*</span>机械型号
            </label>
            <div class="layui-input-inline">
                <input type="text" id="jx_model" name="jx_model" required lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
            </label>
            <button class="layui-btn" type="button" lay-filter="add" lay-submit="">
                保存
            </button>
        </div>
    </form>
</div>
<div class="x-body" id="staffindex" style="display: none;padding-top: 10px">
    <form class="layui-form" id="c4">
        <div class="layui-form-item">
            <label for="yg_num" class="layui-form-label">
                <span class="x-red">*</span>员工编号
            </label>
            <div class="layui-input-inline">
                <input type="text" id="yg_num" name="yg_num" required lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="yg_position" class="layui-form-label">
                <span class="x-red">*</span>岗位
            </label>
            <div class="layui-input-inline">
                <input type="text" id="yg_position" name="yg_position" required lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="yg_star" class="layui-form-label">
                <span class="x-red">*</span>星级
            </label>
            <div class="layui-input-inline">
                <input type="text" id="yg_star" name="yg_star" required lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="yg_name" class="layui-form-label">
                <span class="x-red">*</span>姓名
            </label>
            <div class="layui-input-inline">
                <input type="text" id="yg_name" name="yg_name" required lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
            </label>
            <button class="layui-btn" type="button" lay-filter="add" lay-submit="">
                保存
            </button>
        </div>
    </form>
</div>
<div class="x-body" id="equipmentindex" style="display: none;padding-top: 10px">
    <form class="layui-form" id="c5">
        <div class="layui-form-item">
            <label for="sb_num" class="layui-form-label">
                <span class="x-red">*</span>设备编号
            </label>
            <div class="layui-input-inline">
                <input type="text" id="sb_num" name="sb_num" required lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="mon_name" class="layui-form-label">
                <span class="x-red">*</span>资产名称
            </label>
            <div class="layui-input-inline">
                <input type="text" id="mon_name" name="mon_name" required lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="zc_total" class="layui-form-label">
                <span class="x-red">*</span>资产总额
            </label>
            <div class="layui-input-inline">
                <input type="text" id="zc_total" name="zc_total" required lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="cc_year" class="layui-form-label">
                <span class="x-red">*</span>推销年限
            </label>
            <div class="layui-input-inline">
                <input type="text" id="cc_year" name="cc_year" required lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
            </label>
            <button class="layui-btn" type="button" lay-filter="add" lay-submit="">
                保存
            </button>
        </div>
    </form>
</div>
<div class="x-body" id="otherindex" style="display: none;padding-top: 10px">
    <form class="layui-form" id="c6">
        <div class="layui-form-item">
            <label for="fy_num" class="layui-form-label">
                <span class="x-red">*</span>费用编号
            </label>
            <div class="layui-input-inline">
                <input type="text" id="fy_num" name="fy_num" required lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="fy_type" class="layui-form-label">
                <span class="x-red">*</span>分类名称
            </label>
            <div class="layui-input-inline" v-show="tabs == 1">
                <select id="fy_type" lay-filter="demo1" name="fy_type"
                        class="valid">
                    <option value=" ">请选择</option>
                    <option value="1">办公费</option>
                    <option value="2">差旅费</option>
                    <option value="3">车辆使用费</option>
                    <option value="4">其他费用</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="fy_name" class="layui-form-label">
                <span class="x-red">*</span>名称
            </label>
            <div class="layui-input-inline">
                <input type="text" id="fy_name" name="fy_name" required lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
            </label>
            <button class="layui-btn" type="button" lay-filter="add" lay-submit="">
                保存
            </button>
        </div>
    </form>
</div>
<div style="text-align: center" id="demo8"></div>
</body>
<script type="text/javascript" src="../../js/jquery-3.3.1.js"></script>
<script type="text/javascript" src="../../layui/layui.all.js"></script>
<script type="text/javascript" src="../../js/vue.js"></script>
<script type="text/javascript" src="../../js/main.js"></script>
<script type="text/javascript" src="../../js/excel.js"></script>
<script type="text/javascript" src="../../js/common.js"></script>
<script src="../../layui/formSelects-v4.js"></script>
<script>
    var vm = new Vue({
        el: '#userNumber',
        data: {
            token: '',
            project_id: sessionStorage.getItem('projectopt'),
            page: 1,
            limit: 12,
            tabs: '0',
            arr1: [],
            arr2: [],
            arr3: [],
            arr4: [],
            arr5: [],
            arr6: [],
            savoredit: '1', //1: 保存  2 编辑
            tid: '',  //当前编辑itemid
            permissions:''//权限标识
        },
        created: function () {
            this.token = JSON.parse(sessionStorage.getItem('userinfo')).token;
            this.initData(this.tabs);
            layui.use(['element', 'laypage', 'layer', 'form'], function () {
                var laypage = layui.laypage,
                    layer = layui.layer,
                    form = layui.form,
                    formSelects = layui.formSelects;
                var element = layui.element;
                element.on('tab(types)', function (data) {
                    vm.page = 1;
                    vm.initData(data.index);
                    vm.tabs = data.index;
                });
                formSelects.render();

                //监听提交
                form.on('submit(add)', function (data) {
                    var load = layer.load(2, {
                        shade: [0.6, '#fff'] //0.1透明度的白色背景
                    })
                    var obj = {
                            project_id: sessionStorage.getItem('projectopt')
                        },
                        url = '';
                    if (vm.tabs == 0) {
                        obj.cl_num = data.field.cl_num;
                        obj.cl_name = data.field.cl_name;
                        obj.cl_model = data.field.cl_model;
                        if(vm.savoredit == 1){
                            url = 'api/Classify/materialadd';  //材料
                        }else{
                            url = 'api/Classify/materialeditdo';
                            obj.id = vm.tid;
                        }
                    } else if (vm.tabs == 1) {
                        obj.ry_num = data.field.ry_num;
                        obj.ry_type = data.field.ry_type;
                        obj.ry_name = data.field.ry_name;
                        if(vm.savoredit == 1){
                            url = 'api/Classify/workeradd';  ////人工
                        }else{
                            url = 'api/Classify/workereditdo';
                            obj.id = vm.tid;
                        }
                    } else if (vm.tabs == 2) {
                        obj.jx_num = data.field.jx_num;
                        obj.jx_name = data.field.jx_name;
                        obj.jx_model = data.field.jx_model;
                        if(vm.savoredit == 1){
                            url = 'api/Classify/mechanicaladd';  //机械
                        }else{
                            url = 'api/Classify/mechanicaleditdo';
                            obj.id = vm.tid;
                        }
                    } else if (vm.tabs == 3) {
                        obj.yg_name = data.field.yg_name;
                        obj.yg_num = data.field.yg_num;
                        obj.yg_star = data.field.yg_star;
                        obj.yg_position = data.field.yg_position;
                        if(vm.savoredit == 1){
                            url = 'api/Classify/staffadd';  //职工
                        }else{
                            url = 'api/Classify/staffeditdo';
                            obj.id = vm.tid;
                        }
                    } else if (vm.tabs == 4) {
                        obj.sb_num = data.field.sb_num;
                        obj.mon_name = data.field.mon_name;
                        obj.zc_total = data.field.zc_total;
                        obj.cc_year = data.field.cc_year;
                        if(vm.savoredit == 1){
                            url = 'api/Classify/equipmentadd';  //设备
                        }else{
                            url = 'api/Classify/equipmenteditdo';
                            obj.id = vm.tid;
                        }
                    } else if (vm.tabs == 5) {
                        obj.fy_num = data.field.fy_num;
                        obj.fy_name = data.field.fy_name;
                        obj.type = data.field.fy_type;
                        if(vm.savoredit == 1){
                            url = 'api/Classify/otheradd';  //其它费用
                        }else{
                            url = 'api/Classify/othereditdo';
                            obj.id = vm.tid;
                        }
                    }
                    $.when(PUATTRBUTE.REQUESTFUN(url, obj).done(function (res) {
                            if (res.code == 1) {
                                vm.initData(vm.tabs);
                                layui.layer.msg(res.msg, {time: 1000, icon: 1});
                                var select = 'dd[lay-value=""]';// 设置value
                                $('#fy_type').siblings("div.layui-form-select").find('dl').find(select).click();
                                layer.closeAll();
                                formSelects.render();
                            } else {
                                layui.layer.msg(res.msg, {time: 1000, icon: 2})
                            }
                            layui.layer.close(load)
                        })
                    )
                })
            });
        },
        methods: {
            //初始化数据
            initData: function (index) {
                var url = ''
                if (index == 0) {
                    url = 'api/Classify/materialindex';  //材料
                } else if (index == 1) {
                    url = 'api/Classify/workerindex';  //人工
                } else if (index == 2) {
                    url = 'api/Classify/mechanicalindex';  //机械
                } else if (index == 3) {
                    url = 'api/Classify/staffindex';  //职工
                } else if (index == 4) {
                    url = 'api/Classify/equipmentindex';  //设备
                } else {
                    url = 'api/Classify/otherindex';   //其它费用
                }
                var obj = {
                    project_id: this.project_id,
                    page: this.page,
                    limit: this.limit
                }
                var load = layer.load(2, {
                    shade: [0.6, '#fff'] //0.1透明度的白色背景
                })
                $.when(PUATTRBUTE.REQUESTFUN(url, obj).done(function (res) {
                        layer.close(load);
                        if (res.code == 1) {
                            if (index == 0) {
                                var data = res.data.list;
                                sessionStorage.setItem('material', JSON.stringify(res.data.list));
                                vm.arr1 = data;  //材料
                                if (vm.page == 1) {
                                    vm.initpage(res.data.count);
                                }
                            } else if (index == 1) {
                                var data = res.data.list;
                                sessionStorage.setItem('artificial', JSON.stringify(res.data.list));
                                vm.arr2 = data;  //人工
                                if (vm.page == 1) {
                                    vm.initpage(res.data.count);
                                }
                            } else if (index == 2) {
                                var data = res.data.list;
                                sessionStorage.setItem('mechanical', JSON.stringify(res.data.list));
                                vm.arr3 = data;   //机械
                                if (vm.page == 1) {
                                    vm.initpage(res.data.count);
                                }
                            } else if (index == 3) {
                                var data = res.data.list;
                                sessionStorage.setItem('staff', JSON.stringify(res.data.list));
                                vm.arr4 = data;   //职工
                                if (vm.page == 1) {
                                    vm.initpage(res.data.count);
                                }
                            } else if (index == 4) {
                                var data = res.data.list;
                                sessionStorage.setItem('equipment', JSON.stringify(res.data.list));
                                vm.arr5 = data;   //设备
                                if (vm.page == 1) {
                                    vm.initpage(res.data.count);
                                }
                            } else {
                                var data = res.data.list;
                                sessionStorage.setItem('other', JSON.stringify(res.data.list));
                                for (item in data) {
                                    data[item].fy_type = vm.bidui(data[item].type);
                                }
                                vm.arr6 = data;    //其它费用
                                if (vm.page == 1) {
                                    vm.initpage(res.data.count);
                                }
                            }
                        } else {
                            if(res.msg == "暂无权限"){
                                vm.permissions= 1 ;
                            }
                            layer.msg(res.msg, {time: 1000, icon: 2})
                        }
                    })
                )
            },
            bidui: function(tyid){
                var tyname =  '';
                if(tyid == 1){
                    tyname = '办公费';
                }else if(tyid == 2){
                    tyname = '差旅费';
                }else if(tyid == 3){
                    tyname = '车辆使用费';
                }else if(tyid == 4){
                    tyname = '其他费用';
                }
                return tyname;
             },
            adduser: function(ty, tid) {
                vm.savoredit = ty;
                vm.tid = tid;
                if(vm.permissions == 1){
                    layer.alert("抱歉，您没有此权限！");
                }else {
                    var openty = '',
                        title = '',
                        requurl = '';
                    document.getElementById("cl").reset();
                    document.getElementById("c2").reset();
                    document.getElementById("c3").reset();
                    document.getElementById("c4").reset();
                    document.getElementById("c5").reset();
                    document.getElementById("c6").reset();
                    if (vm.tabs == 0) {
                        openty = $("#materialindex");
                        if(ty == 1){
                            title = '新增材料';
                        }else{
                            title = '编辑材料';
                            requurl = 'api/Classify/materialedit';
                        }
                    } else if (vm.tabs == 1) {
                        openty = $("#workerindex");
                        if(ty == 1){
                            title = '新增人工';
                        }else{
                            title = '编辑人工';
                            requurl = 'api/Classify/workeredit';
                        }
                    } else if (vm.tabs == 2) {
                        openty = $("#mechanicalindex");
                        if(ty == 1){
                            title = '新增机械';
                        }else{
                            title = '编辑机械';
                            requurl = 'api/Classify/mechanicaledit';
                        }
                    } else if (vm.tabs == 3) {
                        openty = $("#staffindex");
                        if(ty == 1){
                            title = '新增职工';
                        }else{
                            title = '编辑职工';
                            requurl = 'api/Classify/staffedit';
                        }
                    } else if (vm.tabs == 4) {
                        openty = $("#equipmentindex");
                        if(ty == 1){
                            title = '新增设备';
                        }else{
                            title = '编辑设备';
                            requurl = 'api/Classify/equipmentedit';
                        }
                    } else {
                        openty = $("#otherindex");
                        if(ty == 1){
                            title = '新增费用';
                        }else{
                            title = '编辑费用';
                            requurl = 'api/Classify/otheredit';
                        }
                    }
                    if(ty == 2){
                        var obj = {
                            project_id: vm.project_id,
                            id: vm.tid
                        }
                        var load = layer.load(2, {
                            shade: [0.6, '#fff'] //0.1透明度的白色背景
                        })
                        $.when(PUATTRBUTE.REQUESTFUN(requurl, obj).done(function (res) {
                                if (res.code == 1) {
                                    if (vm.tabs == 0) {
                                        $('#cl_num').val(res.data.cl_num);
                                        $('#cl_name').val(res.data.cl_name);
                                        $('#cl_model').val(res.data.cl_model);
                                    } else if (vm.tabs == 1) {
                                        $('#ry_num').val(res.data.ry_num);
                                        $('#ry_type').val(res.data.ry_type);
                                        $('#ry_name').val(res.data.ry_name);
                                        $('#cl_num').val(res.data.cl_num);
                                    } else if (vm.tabs == 2) {
                                        $('#jx_num').val(res.data.jx_num);
                                        $('#jx_name').val(res.data.jx_name);
                                        $('#jx_model').val(res.data.jx_model);
                                    } else if (vm.tabs == 3) {
                                        $('#yg_name').val(res.data.yg_name);
                                        $('#yg_num').val(res.data.yg_num);
                                        $('#yg_star').val(res.data.yg_star);
                                        $('#yg_position').val(res.data.yg_position);
                                    } else if (vm.tabs == 4) {
                                        $('#sb_num').val(res.data.sb_num);
                                        $('#mon_name').val(res.data.mon_name);
                                        $('#zc_total').val(res.data.zc_total);
                                        $('#cc_year').val(res.data.cc_year);
                                    } else if (vm.tabs == 5) {
                                        $('#fy_num').val(res.data.fy_num);
                                        $('#fy_name').val(res.data.fy_name);
                                        var select = 'dd[lay-value="'+res.data.type+'"]';// 设置value
                                        $('#fy_type').siblings("div.layui-form-select").find('dl').find(select).click();
                                    }
                                    layer.close(load);
                                    layui.form.render();
                                } else {
                                    layer.msg(res.msg, {time: 1000, icon: 2})
                                }
                            })
                        )
                    }
                        layer.open({
                            type: 1,
                            skin: 'layui-layer-rim', //加上边框
                            area: ['650px', '500px'], //宽高
                            title: title,
                            content: openty
                        });
                }
            },
            //导出
            exports: function () {
                if(this.permissions == 1){
                    layer.alert("抱歉，您没有此权限！");
                }else {
                    var excelname = '',
                        bid = '';
                    if (this.tabs == 0) {
                        bid = 't1';
                        excelname = '材料科.xls';
                    } else if (this.tabs == 1) {
                        bid = 't2';
                        excelname = '人工科.xls';
                    } else if (this.tabs == 2) {
                        bid = 't3';
                        excelname = '机械科.xls';
                    } else if (this.tabs == 3) {
                        bid = 't4';
                        excelname = '职工科.xls';
                    } else if (this.tabs == 4) {
                        bid = 't5';
                        excelname = '设备科.xls';
                    } else if (this.tabs == 5) {
                        bid = 't6';
                        excelname = '其它费用科.xls';
                    }
                    var tableHtml = $('#'+bid);
                    //不能显示class的样式，所以自己重新添加样式 主要为设置边框 格子大小
                    $(tableHtml).css({
                        'border':'1px solid #d5d5d2',
                        'text-align':'center',
                        'border-collapse':'collapse',
                    });
                    $(tableHtml).find('tr td').css({
                        'text-align':'center',
                        'border':'1px solid #d5d5d2',
                        'line-height':'30px',
                        'padding':'0px 10px',
                        'min-width':'100px'
                    });
                    var html = "<html><head><meta charset='utf-8' /></head><body>" + tableHtml[0].outerHTML + "</body></html>";
                    // 实例化一个Blob对象，其构造函数的第一个参数是包含文件内容的数组，第二个参数是包含文件类型属性的对象
                    var blob = new Blob([html], { type: "application/vnd.ms-excel" });
                    var urlA = document.createElement('a');
                    // 利用URL.createObjectURL()方法为a元素生成blob URL
                    $('.table-btn-group').append(urlA);
                    urlA.href = URL.createObjectURL(blob);
                    // 设置文件名，目前只有Chrome和FireFox支持此属性
                    urlA.download = excelname;
                    urlA.click();
                }
            },
            //删除
            del: function (e) {
                var obj = {
                    id: e,
                    project_id: vm.project_id
                }
                var url = ''
                if (vm.tabs == 0) {
                    url = 'api/Classify/materialdel';  //材料
                } else if (vm.tabs == 1) {
                    url = 'api/Classify/workerdel';  //人工
                } else if (vm.tabs == 2) {
                    url = 'api/Classify/mechanicaldel';  //机械
                } else if (vm.tabs == 3) {
                    url = 'api/Classify/staffdel';  //职工
                } else if (vm.tabs == 4) {
                    url = 'api/Classify/equipmentdel';  //设备
                } else {
                    url = 'api/Classify/otherdel';   //其它费用
                }
                layer.confirm('确定删除吗？', {
                    btn: ['确定', '取消'] //按钮
                }, function () {
                    var load = layer.load(2, {
                        shade: [0.6, '#fff'] //0.1透明度的白色背景
                    })
                    $.when(PUATTRBUTE.REQUESTFUN(url, obj).done(function (res) {
                            layer.close(load);
                            if (res.code == 1) {
                                layer.msg(res.msg, {time: 1000, icon: 1})
                                vm.initData(vm.tabs);
                            } else {
                                layer.msg(res.msg, {time: 1000, icon: 2})
                            }
                        })
                    )
                }, function () {
                    layer.closeAll();
                });
            },
            initpage: function (count) {
                //自定义排版
                layui.laypage.render({
                    elem: 'demo8'
                    , count: count
//                    , limits: 12
                    , limit : 12
                    , jump: function (obj, first) {
                        if (!first) {
                            vm.page = obj.curr;
                            vm.initData(vm.tabs);
                        }
                    }
                });
            },
        }
    })
</script>
</html>